<template>
    <div class="message">
        <router-link 
            :to="{path:'/detail',
            query:{ //params
                    id:list1.id,
                }}">
            <div class="first">
                <div class="fir_left">
                    <h4>{{list1.title}}</h4>
                    <div class="p">{{list1.desc}}</div>
                    <span>立即查看</span>
                </div>
                
                <div class="fir_right">
                    <img :src="list1.url" alt="">
                </div>
            </div>
        </router-link>
        <div class="type">{{this.$route.query.type}}</div>
        <div class="list">
            <ul>
                <li v-for="item in list" :key="item.id">
                    <router-link 
                    :to="{path:'/detail',
                    query:{ //params
                            id:item.id,
                        }}">
                        <div class="img"><img :src="item.url" alt=""></div>
                        <div class="name"><p>{{item.title}}</p></div>
                    </router-link>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    name:'message',
    props:['id','type'],
    data() {
        return {
            list:[],
            list1:[]
        }
    },
    mounted() {
        let type = this.$route.query.type
        console.log(type);
        axios.get(`http://localhost:3000/xiaomi?type=${type}`).then(
            response => {
                this.list = response.data.list
                this.list1 = this.list.splice(0,1)[0]
                
                console.log(this.list1);
            },
            error =>{
                console.log('失败');
            }
        )
  },
}
</script>
<style scoped>
a {
    color: #999;
}
    .message {
        width: 10.506rem;
        margin: 2rem 0 0 3.8rem;
    }
    .first {
        display: flex;
        width: 10.2rem;
        height: 3.04rem;
        background-color: #fff;
        border-radius:.4rem;
        overflow: hidden;
    }
    .fir_left {
        padding-left: .48rem;
        padding-top: .32rem;
    }
    .fir_left h4 {
        color: #666;
        margin-bottom: .1rem;
    }
    .fir_left .p {
       width: 6.92rem;
       height: .62rem;
       overflow: hidden;
       color: #999;
       margin-bottom: .22rem;
    }
    .fir_left span {
        text-decoration: none;
        border: .04rem solid #333;
        color: #333;
        font-size: .1rem;
    }
    .fir_right img {
        padding-top: .12rem;
        width: 2.8rem;
        height: 2.8rem;
    }
    .type {
        font-size: .6rem;
        color: #333;
        font-weight: 700;
        margin: .6rem 0 .2rem 0;
        padding-bottom: .32rem;
        border-bottom: .04rem solid #ccc;
    }
    .list ul li {
        float: left;
        width: 3.5rem;
        height: 3.2rem;
        margin-top: 0.4rem;
        margin-bottom: 0.6rem;
    }
    .img {
        width: 2.08rem;
        height: 2.08rem;
        margin: 0 auto;
    }
    .img img {
        width: 2.08rem;
        height: 2.08rem;
    }
    .name{
        width: 3rem;
        height: 1.3rem;
        overflow: hidden;
        margin: 0 auto;
        
    }
    .name p {
        text-align: center;
        font-size: .48rem;
    }
</style>
